package com.warm.jpa.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @Date: 2019/8/26
 * @Author: LChuang
 * @Description: Swagger2 example
 */
@RestController
@RequestMapping("/test")
@Api(value = "Swagger2 Test", protocols = "http")
public class Swagger2Controller {

    @ApiOperation(
            value = "test swagger2",
            notes = "return hello swagger2!",
            response = String.class
    )
    @RequestMapping(value = "/testSwagger2", method = RequestMethod.GET)
    public String testSwagger2(@RequestParam(value = "customName", required = false) String customName){
        StringBuilder msg = new StringBuilder();
        if(customName != null && !"".equals(customName)) {
            msg.append(customName).append(":");
        }
        msg.append("Hello Swagger2");
        return msg.toString();
    }

    @ApiOperation("Test PathVariable")
    @RequestMapping(value = "/testPathVariable/{customName}", method = RequestMethod.GET)
    public String testPathVariable(@PathVariable(value = "customName") String customName) {
        StringBuilder msg = new StringBuilder();
        msg.append(customName).append(":").append("Hello Swagger2");
        return msg.toString();
    }

}
